class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     *
     * 
     * @param param string字符串 
     * @return string字符串
     */
    string compressString(string param) {
        // write code here
        string res = "";
        int left=0, right=0;
        
        while(right < param.length()){
            while(right < param.length() && param[right] == param[left]){
                right++;
            }
            res.push_back(param[left]);
            if(right - left > 1){
                res += to_string(right - left);
            }
            left=right;
        }
        
        return res;
    }
};
